<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
		<style type="text/css">
			.aui-chat .aui-chat-header {
				margin-bottom: 0px;
			}
			.aui-chat .aui-chat-content_img {
				color: #212121;
				font-size: 0.7rem;
				border-radius: 0.2rem;
				min-height: 2rem;
				min-width: 4rem;
				position: relative;
				padding: 0.3rem;
				max-width: 44%;
				word-break: break-all;
				word-wrap: break-word;
			}
			.aui-chat .aui-chat-content_img img {
				max-width: 100%;
				display: inline;
				border-radius: 0.2rem;
			}
			.aui-chat .aui-chat-left .aui-chat-content_img {
				background-color: #ffffff;
				float: left;
				left: 0.5rem;
			}
			.aui-chat .aui-chat-right .aui-chat-content_img {
				background-color: #b3e5fc;
				right: 0.5rem;
				float: right;
			}
			.voice {
				height: 1.3rem;
				line-height: 1.3rem;
				width: 4rem;
				position: relative;
				background-image: url(../../res/ChatBox/stop.png);
				background-repeat: no-repeat;
				background-position: 0 -0.1rem;
				background-size: 1.4rem auto;
				padding-left: 1.4rem;
				color: #424242;
			}
			.chat_share {
			background-color:#333;
			color:#fff;
			/*width:60%;*/
			border-radius: 5px;
			margin-bottom: 3px;
			display: none;
			z-index: 10;
			position: absolute;

			}
			.chat_share_left{
				left:100px;
				/*margin-left: 50px;*/
			}
			.chat_share_right{
				right: 100px;
				/*top: 10px;*/
				/*margin-right: 50px;*/
			}
			.chat_share span{
				/*width: 23%;*/
				/*-webkit-transform: scale(0.5, 0.8);*/
				display: inline-block;
				font-size: 13px;
				text-align: center;
				padding: 6px 12px;
				border-right: .1px solid #fff;
			}
			.openurl{
				color: #4290FF;
			}
			.ddd{
				width: 100%;
				height:44px;
				background-color:pink;
				position: fixed;
				bottom: 0;
				z-index: 99999;
			}
			.ban_word{
				text-align: center;
				font-size: 12px
			}
			.sign_undefined{
				background-color: #8DE6E1;
				padding: 2px 3px;
				border-radius: 2px;
				margin-right: 2px;
				color: #ffffff;
			}
			.sign_0{
				background-color:#8DE6E1;
				padding: 2px 3px;
				border-radius: 2px;
				margin-right: 2px;
				color: #ffffff;
			}
			.sign_1{
				background-color:#D185DE;
				padding: 2px 3px;
				border-radius: 2px;
				margin-right: 2px;
				color: #ffffff;
			}
			.sign_2{
				background-color:#ACD37F;
				padding: 2px 3px;
				border-radius: 2px;
				margin-right: 2px;
				color: #ffffff;
			}
			.sign_3{
				background-color:#FFC265;
				padding: 2px 3px;
				border-radius: 2px;
				margin-right: 2px;
				color: #ffffff;
			}
			.sign_4{
				background-color:#FE9595;
				padding: 2px 3px;
				border-radius: 2px;
				margin-right: 2px;
				color: #ffffff;
			}
		</style>
	</head>
	<body>
		<section class="aui-chat" id="msglist">
		</section>

	</body>
	<script type="text/javascript" src="../../script/api.js" ></script>
	<script src="../../script/vue.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/url.js"></script>
	<script  src="../../script/app.js" ></script>
	<script  src="../../script/zepto.min.js"></script>
	<script type="text/javascript">
	var obj ;
	var timeOutEvent=0;
	var is_ban = false;

	function reload_event() {
		var parentObj =  $api.domAll('.aui-chat-item');
		$(".chat_share").click(function(event) {
							event.stopPropagation();
					});
		for (var i = 0; i < parentObj.length; i++) {
			var ele = parentObj[i];
			ele.addEventListener("touchstart", function (e) {
				// console.log(e.target.innerHTML);
				var jobject = $(e.target)[0];
					 timer = setTimeout(function () {
							 e.preventDefault();
							 var scrolltop = $(e.target).offset().top;
							 var jobject = $(e.target)[0];
							//  e.target.prev().prev().show();
							 var dataid =$(e.target).data("id");
							 $('.chat_share').hide();
							 $('#shareitem'+dataid).css('top',scrolltop-25);
							 $('#shareitem'+dataid).show();
							//  $(e.target).prev().prev().css('top',$(e.target).offset().top)
							//  LongPress(ele);
					 }, 500);
			 });
			 ele.addEventListener("touchmove", function (e) {
					 clearTimeout(timer);
					 timer = 0;
			 });
			 ele.addEventListener("touchend", function (e) {
					 clearTimeout(timer);
					 return false;
			 });
		}

		 $api.dom('body').addEventListener("touchstart", function (e) {

			if($(e.target)[0].tagName != 'SPAN' ){
				$('.chat_share').hide();

			}

			});

		 function LongPress(obj){
				 timeOutEvent = 0;
				//  alert('ssssss');
				 $('.chat_share').hide();
				 $(obj).prev().prev().show();
				 $(obj).prev().prev().css('top',$(obj).offset().top)
		 }
	}

		function openurl(url_scheme){
			var open = url_scheme.indexOf('http')>-1?url_scheme:'http://'+url_scheme;
			 api.openApp({
							iosUrl: open,
					 androidPkg: "android.intent.action.VIEW",
						mimeType: "text/html",
						uri: open,
			 });
		}

		function copy(text){
		var clipBoard = api.require('clipBoard');
		clipBoard.set({
				value: text
		}, function (ret) {
				if (ret) {
						api.toast({
								msg: '已复制到剪贴板',
								location : 'middle'
						});
						$('.chat_share').hide();

				}
		});
		}
		function del(messageId){
			var rong = api.require('rongCloud2');

			rong.deleteMessages({
					messageIds: [messageId]
			}, function(ret, err) {

					if(ret.status=='success'){
						$api.remove($api.dom('.item'+messageId));
						$('.chat_share').hide();

					}
			})
		}
		function share(item){
			$('.chat_share').hide();

			api.openWin({
					name: 'frame_book',
					url: './frame_book.html',
					pageParam: {
							item: item,
							group_id:api.pageParam.group_id
					}
			});


		}
		function recall(messageId){
			var rong = api.require('rongCloud2');

			rong.recallMessage({
						messageId : messageId
				}, function(ret, err){
					if (ret.success) {
						$api.remove($api.dom('.item'+messageId));
						// $api.html($api.dom('.item'+messageId), '您撤回了一条信息');
					}else {

					}
		})
		}
		// 定义全局时间
		var friends_mark;
		var chatTime = new Object()
		chatTime.firstChatTime = ''
		chatTime.lastChatTime = null
		function get_markname(member_id) {
			return friends_mark[member_id];
		}
		var list=[]
		apiready = function() {

			// var data = {
			// 	member_id: getPrefs('member_id'),
			// };
			// var callback = function (ret) {
			// 	list = ret.content;
			// };
			// pinet.post(URL.sensitiveWordList, data, callback);

			var rong = api.require('rongCloud2');
			var UIChatBox = api.require('UIChatBox');
			friends_mark = getPrefs('friends_mark')?JSON.parse(getPrefs('friends_mark')):{};
            var forbidden = false;
			if( api.pageParam.is_ban == 1 && api.pageParam.is_ban_manager == 1 && api.pageParam.role == 3){
				forbidden = false
			}
			else if( api.pageParam.is_ban == 1 && api.pageParam.is_ban_manager == 1 && api.pageParam.role == 2){
				forbidden = false
			}
		else	if( api.pageParam.is_ban == 1 && api.pageParam.is_ban_manager == 1 && api.pageParam.role == 1){
				forbidden = true
			}
		else	if( api.pageParam.is_ban == 1 && api.pageParam.is_ban_manager == 0 && api.pageParam.role == 3){
				forbidden = false
			}
		else	if( api.pageParam.is_ban == 1 && api.pageParam.is_ban_manager == 0 && api.pageParam.role == 2){
				forbidden = true
			}
		else	if( api.pageParam.is_ban == 1 && api.pageParam.is_ban_manager == 0 && api.pageParam.role == 1){
				forbidden = true
			}
			if( api.pageParam.is_ban == 0 ){
				forbidden = false
			}
			api.sendEvent({
				name: 'againrong'
			})
			getLatestMessages(api.pageParam.clan_im_id, 'GROUP');
			api.addEventListener({
					name: 'rload_message'
			}, function (ret, err) {
				getLatestMessages(api.pageParam.clan_im_id, 'GROUP');
			});
			UIChatBox.open({
				placeholder : '',
				maxRows : 4,
				emotionPath : 'widget://res/ChatBox/emotion',
				disableSendMessage:forbidden,
				texts : {
					recordBtn : {
						normalTitle : '按住  说话',
						activeTitle : '松开  结束'
					},
					sendBtn : {
						title : '发送'
					}
				},
				styles : {
					inputBar : {
						borderColor : '#ececec',
						bgColor : '#fbfbfb'
					},
					inputBox : {
						borderColor : '#B3B3B3',
						bgColor : '#FFFFFF'
					},
					emotionBtn : {
						normalImg : 'widget://res/ChatBox/face1.png'
					},
					extrasBtn : {
						normalImg : 'widget://res/ChatBox/add1.png'
					},
					keyboardBtn : {
						normalImg : 'widget://res/ChatBox/key1.png'
					},
					speechBtn : {
						normalImg : 'widget://res/ChatBox/rec.png'
					},
					recordBtn : {
						normalBg : '#50b6dc',
						activeBg : '#3FBC7D',
						color : '#FFF',
						size : 16
					},
					indicator : {
						target : 'both',
						color : '#c4c4c4',
						activeColor : '#9e9e9e'
					},
					sendBtn : {
						titleColor : '#ffffff',
						bg : '#12b7f5',
						activeBg : '#1ba1d4',
						titleSize : 14
					}
				},
				extras : {
					titleSize : 12,
					titleColor : '#a3a3a3',
					isAdaptScreenSize:true,
					isCenterDisplay:false,
					btns : [{
						title : '相册图片',
						normalImg : 'widget://res/ChatBox/1_xiangche_1.png',
						activeImg : 'widget://res/ChatBox/1_xiangche_2.png'
					}, {
						title : '相机拍照',
						normalImg : 'widget://res/ChatBox/1_paishe_1.png',
						activeImg : 'widget://res/ChatBox/1_paishe_2.png'
					}]
				}
			}, function(ret, err) {
				if(is_ban){
					api.toast({
							msg: '禁言中',
							duration: 2000,
							location: 'middle'
					});
					return;
				}
				var eventType = ret.eventType;
				var msg = ret.msg;
				if(eventType == 'send'){
					if(!msg){
						return ;
					}
					for (var i = 0; i < list.length; i++) {
						var mgc = list[i].sensitive_word;
						if (msg.indexOf(mgc) != -1) {
							var data = {
								member_id: getPrefs('member_id'),
								sensitive_word_id: list[i].id,
								send_content: msg,
								group_id: api.pageParam.group_id
							};
							var callback = function (ret) {
							};
							pinet.post(URL.submitSensitiveWord, data, callback);
						}
					}
				}
				if (eventType == 'clickExtras') {

					if (ret.index == 0) {
						getPicture('library')
						pageDown(300);
					} else if (ret.index == 1) {
						getPicture('camera')
						pageDown(300);
					}else if (ret.index == 2) {
						getfile()
						pageDown(300);
					}
				}
				if (eventType == 'send') {
					if ($api.trimAll(ret.msg) == '') {
						api.toast({
							msg : '不能发送空白消息',
							duration : 1000,
							location : 'center'
						});
					} else {
						var extra = {
							user : getPrefs('member_id'),
							username : api.pageParam.nickname?api.pageParam.nickname:getPrefs('username'),
							tx : getPrefs('portrait'),
							group_zh : api.pageParam.group_zh,
							group_tx : api.pageParam.group_tx,
							group_id : api.pageParam.group_id,
							sign_level:1
						};
						rong.sendTextMessage({
							conversationType : 'GROUP',
							targetId : api.pageParam.clan_im_id,
							text : msg,
							extra : JSON.stringify(extra)
						}, function(ret, err) {
                            console.log(JSON.stringify(ret));
                            console.log(JSON.stringify(err));

							if (ret.status == 'prepare') {
								xx = ret.result.message.content.text.replace(reg, function(a, b) {
									return face[a] ? face[a] : a;
								});
								formatTime(Number(chatTime.firstChatTime))
								var html = '';
								html +='<div class="item'+ret.result.message.messageId+'">';
								html += '<div class="aui-chat-header" data-id="' + ret.result.message.messageId + '">' + ( chatTime.showTime ? sj(chatTime.firstChatTime) : '') + '</div>';
								html += '<div class="chat_share chat_share_right" id="shareitem'+ret.result.message.messageId+'">';
								html +=	'<span onClick="share(\''+ret.result.message.content.text+'\')">转发</span>';
								html +=	'<span onClick="copy(\''+ret.result.message.content.text+'\')">复制</span>';
								html +=	'<span onClick="del('+ret.result.message.messageId+')">删除</span>';
								html +=	'<span style="border:none" onclick="recall('+ret.result.message.messageId+')">撤回</span> </div>';
								html +=	'<div style="clear:both"></div>';
								html += '<div class="aui-chat-item aui-chat-right">';
								html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
								html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
								html += '	       <div class="aui-chat-content" data-id="' + ret.result.message.messageId + '">';
								html += '		        <div class="aui-chat-arrow"></div>';
								if(isURL(xx)){
									html += '<span class="openurl" onclick="openurl(\''+xx+'\')">';
									html += xx;
									html += '</span>';
								}else{
									html += xx;
								}
								html += '               </div>';
								html += '	  </div>';
								html += '</div>';
								html += '</div>';
								$api.append($api.dom('#msglist'), html);
								reload_event();
								pageDown(300);
								//刷新会话列表
								api.sendEvent({
									name : 'hhxx'
								});
							}
						});
					}
				}
			});
			UIChatBox.addEventListener({
				target : 'inputBar',
				name : 'move'
			}, function(ret, err) {
				if(ret.panelHeight>0){
					// pageDown(300);
					var wh = api.pageParam.h-ret.panelHeight-45
					api.setFrameAttr({
						name : 'frame_group',
						rect : {
							h: wh,
						}
					});
					pageDown(300);
				}
				if(ret.panelHeight == 0){
					var wh = api.pageParam.h- ret.inputBarHeight ;
					api.setFrameAttr({
						name : 'frame_group',
						rect : {
							h: wh
						}
					});
				}
			});
			api.addEventListener({
				name : 'new_msg'
			}, function(ret, err) {
				var html = '';
				var rs=ret.value.msg
				if (rs.conversationType == 'GROUP' && rs.targetId == api.pageParam.clan_im_id) {
					var extra = transExtra(rs.content.extra);

					if (rs.objectName == 'RC:TxtMsg') {
						jsxx = rs.content.text.replace(reg, function(a, b) {
							return face[a] ? face[a] : a;
						});
						if(transExtra(rs.content.extra).type==1){
							html += '<div class="ban_word">'+rs.content.text+'</div>';
							api.sendEvent({
								name : 'reload_ban'
							});
							is_ban = true;
						}else if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
							html +='<div class="item'+rs.messageId+'">';
							html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
							html +=	'<span onClick="share('+rs.content.text+')">转发</span>';
							html +=	'<span onClick="copy(\''+rs.content.text+'\')">复制</span>';
							html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
							html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + sj(rs.sentTime) + '</div>';
							html += '<div class="aui-chat-item aui-chat-right">';
							html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
							// html += '	       <div class="aui-chat-content">';
							// html += '		        <div class="aui-chat-arrow"></div>';
							// html += jsxx;
							if(transExtra(rs.content.extra).mtype==undefined){
								html += '	       <div class="aui-chat-content" data-id="' + rs.messageId + '">';
								html += '		        <div class="aui-chat-arrow"></div>';
								// html += jsxx;
								if(isURL(jsxx)){
									html += '<span class="openurl" onclick="openurl(\''+jsxx+'\')">';
									html += jsxx;
									html += '</span>';
								}else{
									html += jsxx;
								}
							}else{
								html += '	       <div class="aui-chat-content aui_chat-content-file-send" onclick="openfile(\'' + transExtra(rs.content.extra).fileUrl + '\')">';
								html += '		        <div class="aui-chat-arrow"></div>';
								html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(transExtra(rs.content.extra).type)+'.png"/>';
								html +='<div style="float:right;margin-left:10px">';
								html +='<div class="aui-file-name">'+getSubStr(transExtra(rs.content.extra).name)+'</div>';
								html +='<div class="aui-file-size">'+transExtra(rs.content.extra).size+'</div>';
								html +='</div>'
							}
							html += '               </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';
						} else {
							html +='<div class="item'+rs.messageId+'">';
							html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
							html +=	'<span onClick="share('+rs.content.text+')">转发</span>';
							html +=	'<span onClick="copy(\''+rs.content.text+'\')">复制</span>';
							html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + sj(rs.sentTime) + '</div>';
							html += '<div class="aui-chat-item aui-chat-left">';
							html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
							// html += '	       <div class="aui-chat-content">';
							// html += '		        <div class="aui-chat-arrow"></div>';
							// html += jsxx;
							if(transExtra(rs.content.extra).mtype==undefined){
								html += '	       <div class="aui-chat-content" data-id="' + rs.messageId + '">';

								html += '		        <div class="aui-chat-arrow"></div>';
								// html += jsxx;
								if(isURL(jsxx)){
									html += '<span class="openurl" onclick="openurl(\''+jsxx+'\')">';
									html += jsxx;
									html += '</span>';
								}else{
									html += jsxx;
								}
							}else{
								html += '	       <div class="aui-chat-content aui_chat-content-file-receive" onclick="openfile(\'' + transExtra(rs.content.extra).fileUrl + '\')">';
								html += '		        <div class="aui-chat-arrow"></div>';
								html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(transExtra(rs.content.extra).type)+'.png"/>';
								html +='<div style="float:right;margin-left:10px">';
								html +='<div class="aui-file-name">'+getSubStr(transExtra(rs.content.extra).name)+'</div>';
								html +='<div class="aui-file-size">'+transExtra(rs.content.extra).size+'</div>';
								html +='</div>'
							}
							html += '               </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';
						}
					} else if (rs.objectName == 'RC:ImgMsg') {
						var bpic = rs.content.imageUrl;
						var spic = rs.content.thumbPath;
						if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
							html +='<div class="item'+rs.messageId+'">';
							html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
							html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
							html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + sj(rs.sentTime) + '</div>';
							html += '<div class="aui-chat-item aui-chat-right">';
							html += '	  <div class="aui-chat-media" ><img src="' + getPrefs('portrait') + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
							html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
							html += '		        <div class="aui-chat-arrow"></div>';
							html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
							html += '          </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';

						} else {
							html +='<div class="item'+rs.messageId+'">';
							html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
							html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + sj(rs.sentTime) + '</div>';
							html += '<div class="aui-chat-item aui-chat-left">';
							html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+extra.sign_level+'">'+getSignInfo(extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
							html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
							html += '		        <div class="aui-chat-arrow"></div>';
							html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
							html += '          </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';
						}
					} else if (rs.objectName == 'RC:VcMsg') {
						if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
							html +='<div class="item'+rs.messageId+'">';
							html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
							html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
							html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + sj(rs.sentTime) + '</div>';
							html += '<div class="aui-chat-item aui-chat-right">';
							html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
							html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
							html += '		        <div class="aui-chat-arrow"></div>';
							html += '<div onclick="play(this,\'' + rs.content.voicePath + '\')" class="voice"> ' + rs.content.duration + ' "</div>';
							html += '          </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';
						} else {
							html +='<div class="item'+rs.messageId+'">';
							html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
							html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + sj(rs.sentTime) + '</div>';
							html += '<div class="aui-chat-item aui-chat-left">';
							html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+extra.sign_level+'">'+getSignInfo(extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
							html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
							html += '		        <div class="aui-chat-arrow"></div>';
							html += '<div onclick="play(this,\'' + rs.content.voicePath + '\')" class="voice"> ' + rs.content.duration + ' "</div>';
							html += '          </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';
						}
					}
				}
				$api.append($api.dom('#msglist'), html);
				reload_event();
				pageDown(300);
			});
			//下拉刷新
			// api.setCustomRefreshHeaderInfo({
			// 	bgColor : '#ffffff',
			// 	image : {
			// 		pull : ['widget://image/1.png', 'widget://image/2.png', 'widget://image/3.png', 'widget://image/4.png', 'widget://image/5.png', 'widget://image/6.png', 'widget://image/7.png', 'widget://image/8.png'],
			// 		load : ['widget://image/8.png', 'widget://image/7.png', 'widget://image/6.png', 'widget://image/5.png', 'widget://image/4.png', 'widget://image/3.png', 'widget://image/2.png', 'widget://image/1.png']
			// 	}
			// }, function() {
			// 	getHistoryMessages(api.pageParam.group_id, 'GROUP');
			// 	setTimeout(function() {
			// 		api.refreshHeaderLoadDone();
			// 	}, 3000)
			// });
			setRefreshHeaderInfo(load_history);

			UIChatBox.addEventListener({
				target : 'recordBtn',
				name : 'press'
			}, function(ret, err) {
				sj1 = new Date().getTime();
				if (ret) {
					var savePath = 'fs://lysd_' + (+new Date()) + '.amr';
					api.startRecord({
						path : savePath
					});
				}
			});
			UIChatBox.addEventListener({
				target : 'recordBtn',
				name : 'move_in'
			}, function(ret, err) {
				sj1 = new Date().getTime();
				if (ret) {
					var savePath = 'fs://lysd_' + (+new Date()) + '.amr';
					api.startRecord({
						path : savePath
					});
				}
			});
			UIChatBox.addEventListener({
				target : 'recordBtn',
				name : 'press_cancel'
			}, function(ret, err) {
				var sj2 = new Date().getTime() - sj1;
				if (sj2 <= 2000) {
					stopRecord();
					api.toast({
						msg : '语音时间较短，请重新录音',
						duration : 3000,
						location : 'middle'
					});
				} else if (sj2 > 2000) {
					api.stopRecord(function(ret, err) {
						if (ret.duration > 0) {
							var path = ret.path;
							var duration = ret.duration;
							var extra = {
								user : getPrefs('member_id'),
								username : api.pageParam.nickname?api.pageParam.nickname:getPrefs('username'),
								tx : getPrefs('portrait'),
								group_zh : api.pageParam.group_zh,
								group_tx : api.pageParam.group_tx,
								group_id : api.pageParam.group_id,
								sign_level:api.pageParam.sign_level
							};
							rong.sendVoiceMessage({
								conversationType : 'GROUP',
								targetId : api.pageParam.clan_im_id,
								voicePath : path,
								duration : duration,
								extra : JSON.stringify(extra)
							}, function(ret, err) {
								if (ret.status == 'prepare') {
									yy = ret.result.message.content.voicePath;
									sj_len = ret.result.message.content.duration;
								} else if (ret.status == 'success') {
									var html = '';
									html +='<div class="item'+ret.result.message.messageId+'">';
									html += '<div class="chat_share chat_share_right" id="shareitem'+ret.result.message.messageId+'">';
									// html +=	'<span onClick="share('+ret.result.message+')">转发</span>';
									html +=	'<span onClick="del('+ret.result.message.messageId+')">删除</span>';
									html +=	'<span style="border:none" onclick="recall('+ret.result.message.messageId+')">撤回</span> </div>';
									html +=	'<div style="clear:both"></div>';
									html += '<div class="aui-chat-item aui-chat-right">';
									html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
									html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
									html += '	       <div class="aui-chat-content_img" data-id="' + ret.result.message.messageId + '">';
									html += '		        <div class="aui-chat-arrow"></div>';
									html += '<div onclick="play(this,\'' + yy + '\')" class="voice"> ' + sj_len + ' "</div>';
									html += '               </div>';
									html += '	  </div>';
									html += '</div>';
									html += '</div>';
									$api.append($api.dom('#msglist'), html);
									reload_event();
									pageDown(200);
									//刷新会话列表
									api.sendEvent({
										name : 'hhxx'
									});
								} else if (ret.status == 'error') {
									api.toast({
										msg : '语音发送失败'
									});
								}
							});
						}
					});
				}
			});
			UIChatBox.addEventListener({
				target : 'recordBtn',
				name : 'move_out_cancel'
			}, function(ret, err) {
				var sj2 = new Date().getTime() - sj1;
				if (sj2 <= 2000) {
					stopRecord();
					api.toast({
						msg : '语音时间较短，请重新录音',
						duration : 3000,
						location : 'middle'
					});
				} else if (sj2 > 2000) {
					api.stopRecord(function(ret, err) {
						if (ret.duration > 0) {
							var path = ret.path;
							var duration = ret.duration;
							var extra = {
								user : getPrefs('member_id'),
								username : api.pageParam.nickname?api.pageParam.nickname:getPrefs('username'),
								tx : getPrefs('portrait'),
								group_zh : api.pageParam.group_zh,
								group_tx : api.pageParam.group_tx,
								group_id : api.pageParam.group_id,
								sign_level:api.pageParam.sign_level
							};
							rong.sendVoiceMessage({
								conversationType : 'GROUP',
								targetId : api.pageParam.clan_im_id,
								voicePath : path,
								duration : duration,
								extra : JSON.stringify(extra)
							}, function(ret, err) {
								if (ret.status == 'prepare') {
									yy = ret.result.message.content.voicePath;
									sj_len = ret.result.message.content.duration;
								} else if (ret.status == 'success') {
									var html = '';
									html +='<div class="item'+ret.result.message.messageId+'">';
									html += '<div class="chat_share chat_share_right" id="shareitem'+ret.result.message.messageId+'">';
									// html +=	'<span onClick="share('+ret.result.message+')">转发</span>';
									html +=	'<span onClick="del('+ret.result.message.messageId+')">删除</span>';
									html +=	'<span style="border:none" onclick="recall('+ret.result.message.messageId+')">撤回</span> </div>';
									html +=	'<div style="clear:both"></div>';
									html += '<div class="aui-chat-item aui-chat-right">';
									html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
									html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
									html += '	       <div class="aui-chat-content_img" data-id="' + ret.result.message.messageId + '">';
									html += '		        <div class="aui-chat-arrow"></div>';
									html += '<div onclick="play(this,\'' + yy + '\')" class="voice"> ' + sj_len + ' "</div>';
									html += '               </div>';
									html += '	  </div>';
									html += '</div>';
									html += '</div>';
									$api.append($api.dom('#msglist'), html);
									reload_event();
									pageDown(200);
									//刷新会话列表
									api.sendEvent({
										name : 'hhxx'
									});
								} else if (ret.status == 'error') {
									api.toast({
										msg : '语音发送失败'
									});
								}
							});
						}
					});
				}
			});
		}
		function checkmember(member_id){
			openWin('../chat/member_info',{uid:member_id,group_id:api.pageParam.group_id})

		}
		function load_history() {
			getHistoryMessages(api.pageParam.clan_im_id, 'GROUP')
		}

		function getfile(){
			var fileBrowser = api.require('fileBrowser');
			fileBrowser.open(function(ret) {
					if (ret) {
							uploadFile(ret.url,ret.name,ret.size);
					}
			});
			fileBrowser.skin({
				skin:2,
		});
		}
		function bytesToSize(bytes) {
			if (bytes === 0) return '0 B';
			var k = 1000, // or 1024
					sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
					i = Math.floor(Math.log(bytes) / Math.log(k));
			return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
		}
		function uploadFile(path,name,size){
			var file_class= name.substring(0,name.indexOf("."));
			var index = name.lastIndexOf(".");

			var suffix = name.substr(index+1);

			var obj = api.require('qiniuUpfile');
			var baseUrl = 'http://rgsqn.tiaocheng-tech.com/'; //七牛给你的测试域名，也可使用自己捆绑的域名youe.xxx.com
			var html = '';
			html += '<div class="aui-chat-item aui-chat-right">';
			html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
			html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
			html += '	       <div class="aui-chat-content aui_chat-content-file-send">';
			html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(suffix)+'.png"/>';
			html +='<div style="float:right;margin-left:10px">';
			html +='<div class="aui-file-name">'+getSubStr(name)+'</div>';
			html +='<div class="aui-file-size">'+bytesToSize(size)+'</div>';
			html +='</div>'
			html += '               </div>';
			html += '<div class="progress '+file_class+'"></div>'
			html += '	  </div>';
			html += '</div>';

			$api.append($api.dom('#msglist'), html);
			reload_event();
			pageDown(300);

			obj.upfile({
					file: path,
					name: name
			}, function(ret, err) {
					if (ret.status) {
							if (ret.oper == "complete") {
									//上传成功后组装访问路径，或直接访问文档
									sendFileMessage(qiniuhost + ret.info.key,name,size,file_class);
									// $api.text(b, baseUrl + ret.info.key);
							} else if (ret.oper == "progress") {
									$api.css($api.dom("."+file_class), 'width:'+ret.percent+'%');
							}
					}
			});
			}
			function sendFileMessage(path,name,size,file_class){
				var index = name.lastIndexOf(".");
				var suffix = name.substr(index+1);
				var extra = {
					user : getPrefs('member_id'),
					username : api.pageParam.nickname?api.pageParam.nickname:getPrefs('username'),
					tx : getPrefs('portrait'),
					group_zh : api.pageParam.group_zh,
					group_tx : api.pageParam.group_tx,
					group_id : api.pageParam.group_id,
					name: name, // 文件名称
					size: bytesToSize(size), // 文件大小，单位自己约定
					type: suffix, // 文件的后缀名，例如 png、js、doc ...
					mtype:'file',
					fileUrl: path, // 文件地址,
					sign_level:api.pageParam.sign_level
				};
				var rong = api.require('rongCloud2');

				rong.sendTextMessage({
					conversationType : 'GROUP',
					targetId : api.pageParam.clan_im_id,
					text : name,
					extra : JSON.stringify(extra)
				}, function(ret, err) {
					if (ret.status == 'prepare') {
						xx = ret.result.message.content.text.replace(reg, function(a, b) {
							return face[a] ? face[a] : a;
						});
					} else if (ret.status == 'success') {
						$api.css($api.dom("."+file_class), 'width:0px');
					}
				});
				}
		function getPicture(type) {
			api.getPicture({
				sourceType : type,
				encodingType : 'jpg',
				mediaValue : 'pic',
				destinationType : 'url',
				allowEdit : false,
				quality : 100,
				saveToPhotoAlbum : false
			}, function(ret, err) {
				if (ret) {
					var extra = {
						user : getPrefs('member_id'),
						username : api.pageParam.nickname?api.pageParam.nickname:getPrefs('username'),
						tx : getPrefs('portrait'),
						group_zh : api.pageParam.group_zh,
						group_tx : api.pageParam.group_tx,
						group_id : api.pageParam.group_id,
						sign_level:api.pageParam.sign_level
					};
					var rong = api.require('rongCloud2');
					rong.sendImageMessage({
						conversationType : 'GROUP',
						targetId : api.pageParam.clan_im_id,
						imagePath : ret.data,
						extra : JSON.stringify(extra)
					}, function(ret, err) {
						if (ret.status == 'prepare') {
							var bpic = ret.result.message.content.imageUrl;
							var spic = ret.result.message.content.thumbPath;
							var html = '';
							html +='<div class="item'+ret.result.message.messageId+'">';
							html += '<div class="chat_share chat_share_right" id="shareitem'+ret.result.message.messageId+'">';
							// html +=	'<span onClick="share('+ret.result.message+')">转发</span>';
							html +=	'<span onClick="del('+ret.result.message.messageId+')">删除</span>';
							html +=	'<span style="border:none" onclick="recall('+ret.result.message.messageId+')">撤回</span> </div>';
							html +=	'<div style="clear:both"></div>';
							html += '<div class="aui-chat-item aui-chat-right">';
							html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
							html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+api.pageParam.sign_level+'">'+getSignInfo(api.pageParam.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
							html += '	       <div class="aui-chat-content_img" data-id="' + ret.result.message.messageId + '">';
							html += '		        <div class="aui-chat-arrow"></div>';
							html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
							html += '          </div>';
							html += '	  </div>';
							html += '</div>';
							html += '</div>';
							$api.append($api.dom('#msglist'), html);
							reload_event();
						}
					});
					var UIChatBox = api.require('UIChatBox');
					UIChatBox.closeBoard();
				} else {
					// api.toast({
					// 	msg : '图像获取失败',
					// 	duration : 3000,
					// 	location : 'bottom'
					// });
					var UIChatBox = api.require('UIChatBox');
					UIChatBox.closeBoard();
				}
			});
		}

		//获取最后一段群会话
		function getLatestMessages(targetId, conversationType) {
			var rong = api.require('rongCloud2');
			rong.getLatestMessages({
				conversationType : conversationType,
				targetId : targetId,
				count : 8
			}, function(ret, err) {
				// console.log(JSON.stringify(ret));
				if (ret.status == 'success') {

					if (ret.result && ret.result.length > 0) {
						var html = '';
						for (var i = ret.result.length - 1; i >= 0; i--) {
							var rs = ret.result[i];

							if(Math.abs(Number(rs.sentTime) - Number(chatTime.firstChatTime)) > 300000){
								chatTime.firstChatTime = rs.sentTime
								chatTime.showTime = true
							}else{
								chatTime.showTime = false
							}
							if(i == ret.result.length - 1){
								chatTime.lastChatTime = rs.sentTime
							}
							if(i == 0){
								chatTime.firstChatTime = chatTime.lastChatTime
							}

							var extra = transExtra(rs.content.extra);
							if (rs.conversationType == 'GROUP' && rs.targetId == api.pageParam.clan_im_id) {
								if (rs.objectName == 'RC:TxtMsg') {
									jsxx = rs.content.text.replace(reg, function(a, b) {
										return face[a] ? face[a] : a;
									});
									if(transExtra(rs.content.extra).type==1){
										html +='<div class="ban_word">'+rs.content.text+'</div>';
									}else if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="share(\''+rs.content.text+'\')">转发</span>';
										html +=	'<span onClick="copy(\''+rs.content.text+'\')">复制</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
										html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-right">';
										html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
										// html += '	       <div class="aui-chat-content">';
										// html += '		        <div class="aui-chat-arrow"></div>';
										// html += jsxx;
										if(transExtra(rs.content.extra).mtype==undefined){
											html += '	       <div class="aui-chat-content" data-id="' + rs.messageId + '">';
											html += '		        <div class="aui-chat-arrow"></div>';
											// html += jsxx;
											if(isURL(jsxx)){
												html += '<span class="openurl" onclick="openurl(\''+jsxx+'\')">';
												html += jsxx;
												html += '</span>';
											}else{
												html += jsxx;
											}
										}else{
											html += '	       <div data-id="' + rs.messageId + '" class="aui-chat-content aui_chat-content-file-send" onclick="openfile(\'' + transExtra(rs.content.extra).fileUrl + '\')">';
											html += '		        <div class="aui-chat-arrow"></div>';
											html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(transExtra(rs.content.extra).type)+'.png"/>';
											html +='<div style="float:right;margin-left:10px">';
											html +='<div class="aui-file-name">'+getSubStr(transExtra(rs.content.extra).name)+'</div>';
											html +='<div class="aui-file-size">'+transExtra(rs.content.extra).size+'</div>';
											html +='</div>'
										}
										html += '               </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									} else {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="share(\''+rs.content.text+'\')">转发</span>';
										html +=	'<span onClick="copy(\''+rs.content.text+'\')">复制</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-left">';
										html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
										// html += '	       <div class="aui-chat-content">';
										// html += '		        <div class="aui-chat-arrow"></div>';
										// html += jsxx;
										if(transExtra(rs.content.extra).mtype==undefined){
											html += '	       <div class="aui-chat-content" data-id="' + rs.messageId + '">';

											html += '		        <div class="aui-chat-arrow"></div>';
											// html += jsxx;
											if(isURL(jsxx)){
												html += '<span class="openurl" onclick="openurl(\''+jsxx+'\')">';
												html += jsxx;
												html += '</span>';
											}else{
												html += jsxx;
											}
										}else{
											html += '	       <div data-id="' + rs.messageId + '" class="aui-chat-content aui_chat-content-file-receive" onclick="openfile(\'' + transExtra(rs.content.extra).fileUrl + '\')">';
											html += '		        <div class="aui-chat-arrow"></div>';
											html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(transExtra(rs.content.extra).type)+'.png"/>';
											html +='<div style="float:right;margin-left:10px">';
											html +='<div class="aui-file-name">'+getSubStr(transExtra(rs.content.extra).name)+'</div>';
											html +='<div class="aui-file-size">'+transExtra(rs.content.extra).size+'</div>';
											html +='</div>'
										}
										html += '               </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									}
								} else if (rs.objectName == 'RC:ImgMsg') {
									var bpic = rs.content.imageUrl;
									var spic = rs.content.thumbPath;
									if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
										// html +=	'<span onClick="share('+rs+')">转发</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
										html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-right">';
										html += '	  <div class="aui-chat-media" ><img src="' + getPrefs('portrait') + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									} else {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="aui-chat-item aui-chat-left">';
										html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									}
								} else if (rs.objectName == 'RC:VcMsg') {
									if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
										// html +=	'<span onClick="share('+rs+')">转发</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
										html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-right">';
										html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '<div onclick="play(this,\'' + rs.content.voicePath + '\')" class="voice"> ' + rs.content.duration + ' "</div>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									} else {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-left">';
										html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '<div onclick="play(this,\'' + rs.content.voicePath + '\')" class="voice"> ' + rs.content.duration + ' "</div>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									}
								}
							}
						}
						console.log(html);
						$api.html($api.dom('#msglist'), html);
						reload_event();
						pageDown(300);
					}
				}
			})
		}

		//下拉加载历史记录
		function getHistoryMessages(targetId, conversationType) {
			var rong = api.require('rongCloud2');
			var oldid = $(".aui-chat-header").first().data("id");
			if(oldid==undefined){
				api.refreshHeaderLoadDone();
				return;
			}
			rong.getHistoryMessages({
				conversationType : conversationType,
				targetId : targetId,
				oldestMessageId : oldid,
				count : 8
			}, function(ret, err) {
				if (ret.status == 'success') {
					var html = '';
					if (ret.result && ret.result.length > 0) {
						for (var i = ret.result.length - 1; i >= 0; i--) {
							var rs = ret.result[i];

							if(Math.abs(Number(rs.sentTime) - Number(chatTime.firstChatTime)) > 300000){
								chatTime.firstChatTime = rs.sentTime
								chatTime.showTime = true
							}else{
								chatTime.showTime = false
							}

							if(!rs.content){
								ret.result.splice(i, 1);
								continue;
							}
							var extra = transExtra(rs.content.extra);
							if (rs.conversationType == 'GROUP' && rs.targetId == api.pageParam.clan_im_id) {
								if (rs.objectName == 'RC:TxtMsg') {
									jsxx = rs.content.text.replace(reg, function(a, b) {
										return face[a] ? face[a] : a;
									});
									if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="share(\''+rs.content.text+'\')">转发</span>';
										html +=	'<span onClick="copy(\''+rs.content.text+'\')">复制</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
										html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-right">';
										html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
										// html += '	       <div class="aui-chat-content">';
										// html += '		        <div class="aui-chat-arrow"></div>';
										// html += jsxx;
										if(transExtra(rs.content.extra).mtype==undefined){
											html += '	       <div class="aui-chat-content" data-id="' + rs.messageId + '">';
											html += '		        <div class="aui-chat-arrow"></div>';
											// html += jsxx;
											if(isURL(jsxx)){
												html += '<span class="openurl" onclick="openurl(\''+jsxx+'\')">';
												html += jsxx;
												html += '</span>';
											}else{
												html += jsxx;
											}
										}else{
											html += '	       <div data-id="' + rs.messageId + '" class="aui-chat-content aui_chat-content-file-send" onclick="openfile(\'' + transExtra(rs.content.extra).fileUrl + '\')">';
											html += '		        <div class="aui-chat-arrow"></div>';
											html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(transExtra(rs.content.extra).type)+'.png"/>';
											html +='<div style="float:right;margin-left:10px">';
											html +='<div class="aui-file-name">'+getSubStr(transExtra(rs.content.extra).name)+'</div>';
											html +='<div class="aui-file-size">'+transExtra(rs.content.extra).size+'</div>';
											html +='</div>'
										}
										html += '               </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									} else {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="share(\''+rs.content.text+'\')">转发</span>';
										html +=	'<span onClick="copy(\''+rs.content.text+'\')">复制</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-left">';
										html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
										// html += '	       <div class="aui-chat-content">';
										// html += '		        <div class="aui-chat-arrow"></div>';
										// html += jsxx;
										if(transExtra(rs.content.extra).mtype==undefined){
											html += '	       <div class="aui-chat-content" data-id="' + rs.messageId + '">';

											html += '		        <div class="aui-chat-arrow"></div>';
											// html += jsxx;
											if(isURL(jsxx)){
												html += '<span class="openurl" onclick="openurl(\''+jsxx+'\')">';
												html += jsxx;
												html += '</span>';
											}else{
												html += jsxx;
											}
										}else{
											html += '	       <div data-id="' + rs.messageId + '" class="aui-chat-content aui_chat-content-file-receive" onclick="openfile(\'' + transExtra(rs.content.extra).fileUrl + '\')">';
											html += '		        <div class="aui-chat-arrow"></div>';
											html +='<img  style="float:left;width:60px"  src="../../res/ChatBox/'+checktype(transExtra(rs.content.extra).type)+'.png"/>';
											html +='<div style="float:right;margin-left:10px">';
											html +='<div class="aui-file-name">'+getSubStr(transExtra(rs.content.extra).name)+'</div>';
											html +='<div class="aui-file-size">'+transExtra(rs.content.extra).size+'</div>';
											html +='</div>'
										}
										html += '               </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									}
								} else if (rs.objectName == 'RC:ImgMsg') {
									var bpic = rs.content.imageUrl;
									var spic = rs.content.thumbPath;
									if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
										// html +=	'<span onClick="share('+rs+')">转发</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
										html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-right">';
										html += '	  <div class="aui-chat-media" ><img src="' + getPrefs('portrait') + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									} else {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="aui-chat-item aui-chat-left">';
										html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '               <img onclick="openImage(\'' + bpic + '\')" src="' + spic + '"/>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									}
								} else if (rs.objectName == 'RC:VcMsg') {
									if (transExtra(rs.content.extra).user == getPrefs('member_id')) {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_right" id="shareitem'+rs.messageId+'">';
										// html +=	'<span onClick="share('+rs+')">转发</span>';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span>';
										html +=	'<span style="border:none" onclick="recall('+rs.messageId+')">撤回</span> </div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-right">';
										html += '	  <div class="aui-chat-media"><img src="' + getPrefs('portrait') + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + api.pageParam.nickname + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '<div onclick="play(this,\'' + rs.content.voicePath + '\')" class="voice"> ' + rs.content.duration + ' "</div>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									} else {
										html +='<div class="item'+rs.messageId+'">';
										html += '<div class="aui-chat-header" data-id="' + rs.messageId + '">' + ( chatTime.showTime ? sj(rs.sentTime) : '') + '</div>';
										html += '<div class="chat_share chat_share_left" id="shareitem'+rs.messageId+'">';
										html +=	'<span onClick="del('+rs.messageId+')">删除</span></div>';
										html +=	'<div style="clear:both"></div>';
										html += '<div class="aui-chat-item aui-chat-left">';
										html += '	  <div class="aui-chat-media"><img src="' + extra.tx + '" /></div>';
										html += '	  <div class="aui-chat-inner"><div class="aui-chat-name"><span class="sign_'+rs.content.extra.sign_level+'">'+getSignInfo(rs.content.extra.sign_level)+'</span>' + (get_markname(extra.user)?get_markname(extra.user):extra.username) + '</div>';
										html += '	       <div class="aui-chat-content_img" data-id="' + rs.messageId + '">';
										html += '		        <div class="aui-chat-arrow"></div>';
										html += '<div onclick="play(this,\'' + rs.content.voicePath + '\')" class="voice"> ' + rs.content.duration + ' "</div>';
										html += '          </div>';
										html += '	  </div>';
										html += '</div>';
										html += '</div>';
									}
								}
							}
						}
						$api.prepend($api.dom('#msglist'), html);
						reload_event();
						api.refreshHeaderLoadDone();
					} else {
						// api.toast({
						// 	msg : '木有了消息啦…'
						// });
						api.refreshHeaderLoadDone();
					}
				}
			})
		}

		//滑动到底部
		function pageDown(time) {
			setTimeout(function() {
				api.pageDown({
					bottom : true,
					animate : true
				}, function(ret) {
				});
			}, time || 0)
		}

		//打开图像
		function openImage(path) {
			var imageBrowser = api.require('imageBrowser');
			imageBrowser.openImages({
				imageUrls : [path],
				showList:false

			});
		}

		//终止录音
		function stopRecord() {
			api.stopRecord(function(ret, err) {
			});
		}

		//播放录音
		function play(el, path) {
			$api.css(el, 'background-image:url(../../res/ChatBox/playing.gif)');
			api.startPlay({
				path : path
			}, function() {
				$api.css(el, 'background-image:url(../../res/ChatBox/stop.png)');
			});
		}

		//表情符号转换
		var reg = /\[.+?\]/g;
		var face = {
			'[微笑]' : '<span><img src="../../res/ChatBox/emotion/Expression_1.png"  width="28"/></span>',
			'[撇嘴]' : '<span><img src="../../res/ChatBox/emotion/Expression_2.png"  width="28" /></span>',
			'[色]' : '<span><img src="../../res/ChatBox/emotion/Expression_3.png"  width="28" /></span>',
			'[发呆]' : '<span><img src="../../res/ChatBox/emotion/Expression_4.png"  width="28" /></span>',
			'[得意]' : '<span><img src="../../res/ChatBox/emotion/Expression_5.png"  width="28" /></span>',
			'[流泪]' : '<span><img src="../../res/ChatBox/emotion/Expression_6.png"  width="28" /></span>',
			'[害羞]' : '<span><img src="../../res/ChatBox/emotion/Expression_7.png"  width="28" /></span>',
			'[闭嘴]' : '<span><img src="../../res/ChatBox/emotion/Expression_8.png"  width="28" /></span>',
			'[睡]' : '<span><img src="../../res/ChatBox/emotion/Expression_9.png"  width="28" /></span>',
			'[笑哭]' : '<span><img src="../../res/ChatBox/emotion/Expression_10.png"  width="28"/></span>',
			'[尴尬]' : '<span><img src="../../res/ChatBox/emotion/Expression_11.png"  width="28"/></span>',
			'[发怒]' : '<span><img src="../../res/ChatBox/emotion/Expression_12.png"  width="28"/></span>',
			'[调皮]' : '<span><img src="../../res/ChatBox/emotion/Expression_13.png"  width="28" /></span>',
			'[呲牙]' : '<span><img src="../../res/ChatBox/emotion/Expression_14.png"  width="28" /></span>',
			'[惊讶]' : '<span><img src="../../res/ChatBox/emotion/Expression_15.png"  width="28" /></span>',
			'[难过]' : '<span><img src="../../res/ChatBox/emotion/Expression_16.png"  width="28" /></span>',
			'[惬意]' : '<span><img src="../../res/ChatBox/emotion/Expression_17.png"  width="28" /></span>',
			'[冷汗]' : '<span><img src="../../res/ChatBox/emotion/Expression_18.png"  width="28" /></span>',
			'[抓狂]' : '<span><img src="../../res/ChatBox/emotion/Expression_19.png"  width="28" /></span>',
			'[抛媚眼]' : '<span><img src="../../res/ChatBox/emotion/Expression_20.png"  width="28" /></span>',
			'[生气]' : '<span><img src="../../res/ChatBox/emotion/Expression_21.png"  width="28" /></span>',
			'[愉快]' : '<span><img src="../../res/ChatBox/emotion/Expression_22.png"  width="28" /></span>',
			'[生病]' : '<span><img src="../../res/ChatBox/emotion/Expression_23.png"  width="28" /></span>',
			'[傲慢]' : '<span><img src="../../res/ChatBox/emotion/Expression_24.png"  width="28" /></span>',
			'[无奈]' : '<span><img src="../../res/ChatBox/emotion/Expression_25.png"  width="28" /></span>',
			'[困]' : '<span><img src="../../res/ChatBox/emotion/Expression_26.png"  width="28" /></span>',
			'[恐惧]' : '<span><img src="../../res/ChatBox/emotion/Expression_27.png"  width="28" /></span>',
			'[愤怒]' : '<span><img src="../../res/ChatBox/emotion/Expression_28.png"  width="28" /></span>',
			'[憨笑]' : '<span><img src="../../res/ChatBox/emotion/Expression_29.png"  width="28" /></span>',
			'[舔嘴]' : '<span><img src="../../res/ChatBox/emotion/Expression_30.png"  width="28" /></span>',
			'[亲亲]' : '<span><img src="../../res/ChatBox/emotion/Expression_31.png"  width="28" /></span>',
			'[晕]' : '<span><img src="../../res/ChatBox/emotion/Expression_32.png"  width="28" /></span>',
			'[衰]' : '<span><img src="../../res/ChatBox/emotion/Expression_33.png"  width="28" /></span>',
			'[汗]' : '<span><img src="../../res/ChatBox/emotion/Expression_34.png"  width="28" /></span>',
			'[委屈]' : '<span><img src="../../res/ChatBox/emotion/Expression_35.png"  width="28" /></span>',
			'[快哭了]' : '<span><img src="../../res/ChatBox/emotion/Expression_36.png"  width="28" /></span>',
			'[阴险]' : '<span><img src="../../res/ChatBox/emotion/Expression_37.png"  width="28" /></span>',
			'[吓]' : '<span><img src="../../res/ChatBox/emotion/Expression_38.png"  width="28" /></span>',
			'[骷髅]' : '<span><img src="../../res/ChatBox/emotion/Expression_39.png"  width="28"/></span>',
			'[搞怪]' : '<span><img src="../../res/ChatBox/emotion/Expression_40.png"  width="28"/></span>',
			'[太阳]' : '<span><img src="../../res/ChatBox/emotion/Expression_41.png"  width="28"/></span>',
			'[月亮]' : '<span><img src="../../res/ChatBox/emotion/Expression_42.png"  width="28" /></span>',
			'[鼓掌]' : '<span><img src="../../res/ChatBox/emotion/Expression_43.png"  width="28" /></span>',
			'[拳头]' : '<span><img src="../../res/ChatBox/emotion/Expression_44.png"  width="28" /></span>',
			'[OK]' : '<span><img src="../../res/ChatBox/emotion/Expression_45.png"  width="28" /></span>',
			'[再见]' : '<span><img src="../../res/ChatBox/emotion/Expression_46.png"  width="28" /></span>',
			'[强壮]' : '<span><img src="../../res/ChatBox/emotion/Expression_47.png"  width="28" /></span>',
			'[赞]' : '<span><img src="../../res/ChatBox/emotion/Expression_48.png"  width="28" /></span>',
			'[踩]' : '<span><img src="../../res/ChatBox/emotion/Expression_49.png"  width="28" /></span>',
			'[爱情]' : '<span><img src="../../res/ChatBox/emotion/Expression_50.png"  width="28" /></span>',
			'[大便]' : '<span><img src="../../res/ChatBox/emotion/Expression_51.png"  width="28" /></span>',
			'[炸弹]' : '<span><img src="../../res/ChatBox/emotion/Expression_52.png"  width="28" /></span>',
			'[音乐]' : '<span><img src="../../res/ChatBox/emotion/Expression_53.png"  width="28" /></span>',
			'[庆祝]' : '<span><img src="../../res/ChatBox/emotion/Expression_54.png"  width="28" /></span>',
			'[闪电]' : '<span><img src="../../res/ChatBox/emotion/Expression_55.png"  width="28" /></span>',
			'[篮球]' : '<span><img src="../../res/ChatBox/emotion/Expression_56.png"  width="28" /></span>',
			'[足球]' : '<span><img src="../../res/ChatBox/emotion/Expression_57.png"  width="28" /></span>',
			'[玫瑰]' : '<span><img src="../../res/ChatBox/emotion/Expression_58.png"  width="28" /></span>',
			'[礼物]' : '<span><img src="../../res/ChatBox/emotion/Expression_59.png"  width="28" /></span>',
			'[彩虹]' : '<span><img src="../../res/ChatBox/emotion/Expression_60.png"  width="28" /></span>',
			'[爱心]' : '<span><img src="../../res/ChatBox/emotion/Expression_61.png"  width="28" /></span>',
			'[心碎]' : '<span><img src="../../res/ChatBox/emotion/Expression_62.png"  width="28" /></span>',
			'[！？]' : '<span><img src="../../res/ChatBox/emotion/Expression_63.png"  width="28" /></span>',
			'[中国]' : '<span><img src="../../res/ChatBox/emotion/Expression_64.png"  width="28" /></span>',
			'[蛋糕]' : '<span><img src="../../res/ChatBox/emotion/Expression_65.png"  width="28" /></span>',
			'[啤酒]' : '<span><img src="../../res/ChatBox/emotion/Expression_66.png"  width="28" /></span>',
			'[咖啡]' : '<span><img src="../../res/ChatBox/emotion/Expression_67.png"  width="28" /></span>',
			'[红酒]' : '<span><img src="../../res/ChatBox/emotion/Expression_68.png"  width="28"/></span>',
			'[米饭]' : '<span><img src="../../res/ChatBox/emotion/Expression_69.png"  width="28"/></span>',
			'[汉堡]' : '<span><img src="../../res/ChatBox/emotion/Expression_70.png"  width="28"/></span>',
			'[甜筒]' : '<span><img src="../../res/ChatBox/emotion/Expression_71.png"  width="28" /></span>',
			'[西瓜]' : '<span><img src="../../res/ChatBox/emotion/Expression_72.png"  width="28" /></span>',
			'[葡萄]' : '<span><img src="../../res/ChatBox/emotion/Expression_73.png"  width="28" /></span>',
			'[柠檬]' : '<span><img src="../../res/ChatBox/emotion/Expression_74.png"  width="28" /></span>',
			'[菠萝]' : '<span><img src="../../res/ChatBox/emotion/Expression_75.png"  width="28" /></span>',
			'[苹果]' : '<span><img src="../../res/ChatBox/emotion/Expression_76.png"  width="28" /></span>',
			'[草莓]' : '<span><img src="../../res/ChatBox/emotion/Expression_77.png"  width="28" /></span>',
			'[老鼠]' : '<span><img src="../../res/ChatBox/emotion/Expression_78.png"  width="28" /></span>',
			'[牛]' : '<span><img src="../../res/ChatBox/emotion/Expression_79.png"  width="28" /></span>',
			'[老虎]' : '<span><img src="../../res/ChatBox/emotion/Expression_80.png"  width="28" /></span>',
			'[兔子]' : '<span><img src="../../res/ChatBox/emotion/Expression_81.png"  width="28" /></span>',
			'[龙]' : '<span><img src="../../res/ChatBox/emotion/Expression_82.png"  width="28" /></span>',
			'[蛇]' : '<span><img src="../../res/ChatBox/emotion/Expression_83.png"  width="28" /></span>',
			'[马]' : '<span><img src="../../res/ChatBox/emotion/Expression_84.png"  width="28" /></span>',
			'[羊]' : '<span><img src="../../res/ChatBox/emotion/Expression_85.png"  width="28" /></span>',
			'[猴子]' : '<span><img src="../../res/ChatBox/emotion/Expression_86.png"  width="28" /></span>',
			'[鸡]' : '<span><img src="../../res/ChatBox/emotion/Expression_87.png"  width="28" /></span>',
			'[狗]' : '<span><img src="../../res/ChatBox/emotion/Expression_88.png"  width="28" /></span>',
			'[猪]' : '<span><img src="../../res/ChatBox/emotion/Expression_89.png"  width="28" /></span>',
			'[猫]' : '<span><img src="../../res/ChatBox/emotion/Expression_90.png"  width="28" /></span>',
			'[T恤]' : '<span><img src="../../res/ChatBox/emotion/Expression_91.png"  width="28" /></span>',
			'[裤子]' : '<span><img src="../../res/ChatBox/emotion/Expression_92.png"  width="28" /></span>',
			'[比基尼]' : '<span><img src="../../res/ChatBox/emotion/Expression_93.png"  width="28" /></span>',
			'[裙子]' : '<span><img src="../../res/ChatBox/emotion/Expression_94.png"  width="28" /></span>',
			'[皮鞋]' : '<span><img src="../../res/ChatBox/emotion/Expression_95.png"  width="28" /></span>',
			'[高跟鞋]' : '<span><img src="../../res/ChatBox/emotion/Expression_96.png"  width="28" /></span>',
			'[帽子]' : '<span><img src="../../res/ChatBox/emotion/Expression_97.png"  width="28" /></span>',
			'[包包]' : '<span><img src="../../res/ChatBox/emotion/Expression_98.png"  width="28" /></span>',
			'[口红]' : '<span><img src="../../res/ChatBox/emotion/Expression_99.png"  width="28" /></span>',
			'[戒指]' : '<span><img src="../../res/ChatBox/emotion/Expression_100.png"  width="28" /></span>',
			'[钻石]' : '<span><img src="../../res/ChatBox/emotion/Expression_101.png"  width="28" /></span>',
			'[皇冠]' : '<span><img src="../../res/ChatBox/emotion/Expression_102.png"  width="28" /></span>',
			'[邮件]' : '<span><img src="../../res/ChatBox/emotion/Expression_103.png"  width="28" /></span>',
			'[公文包]' : '<span><img src="../../res/ChatBox/emotion/Expression_104.png"  width="28" /></span>',
			'[涨停]' : '<span><img src="../../res/ChatBox/emotion/Expression_105.png"  width="28" /></span>',
			'[跌停]' : '<span><img src="../../res/ChatBox/emotion/Expression_106.png"  width="28" /></span>',

		};
		function formatTime(oldtime){
			if(Number((new Date()).getTime()) - Number(oldtime) > 300000){
				chatTime.firstChatTime = (new Date()).getTime()
				chatTime.showTime = true
			}else{
				chatTime.showTime = false
			}
		}
		function getSignInfo(level){
			return getsignStyle(level).level_name;
		}
		//时间差计算
		function sj(sj) {
			var nowt = new Date().getTime();
			var a = new Date(parseInt(sj));
			var b = new Date(parseInt(nowt));
			var date1 = Date.parse(format(a, 4));
			var date2 = Date.parse(format(b, 4));
			var xxsj = Math.ceil((date2 - date1) / (60 * 1000))
			var tian1 = new Date(date1).getDate()
			var tian2 = new Date(date2).getDate()

			if (xxsj <= 1 && xxsj >= 0) {
				return "就刚才";
			} else if (xxsj <= 10 && xxsj > 1) {
				return xxsj + "分钟前";
			} else if (xxsj <= 60 && xxsj > 10) {
				return format(a, 1);
			} else if (xxsj <= 2879 && xxsj > 60) {
				if(tian2 - tian1 == 1){
					return '昨天' + format(a, 1);
				}else{
					return format(a, 1);
				}
			} else if (xxsj <= 10080 && xxsj > 2879) {
				return format(a, 2);
			} else if (xxsj > 10080) {
				return format(a, 5);
			} else {
				return format(a, 5);
			}
		}

		//json格式转换
		function transExtra(arg) {
			var result = '';
			try {
				result = eval('(' + arg + ')');
			} catch (e) {
				result = arg.slice(1, -1);
			} finally {
			}
			return result;
		}

		//格式化时间
		function format(now, type) {
			var show_day = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
			var year = now.getFullYear().toString();
			var month = (now.getMonth() + 1).toString();
			var day = (now.getDate()).toString();
			var tian = now.getDay().toString();
			var hour = (now.getHours()).toString();
			var minute = (now.getMinutes()).toString();
			var second = (now.getSeconds()).toString();
			if (hour.length == 1) {
				hour = "0" + hour;
			}
			if (minute.length == 1) {
				minute = "0" + minute;
			}
			if (second.length == 1) {
				second = "0" + second;
			}
			if (type == 1) {
				var dateTime = hour + ":" + minute;
			} else if (type == 2) {
				var dateTime = show_day[tian] + " " + hour + ":" + minute
			} else if (type == 3) {
				var dateTime = year + "-" + month + "-" + day
			} else if (type == 4) {
				var dateTime = year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second;
			} else if (type == 5) {
				var dateTime = year + "年" + month + "月" + day + "日" + " " + hour + ":" + minute + ":" + second;
			} else if (type == 6) {
				var dateTime = month + "月" + day + "日"+ " " + hour + ":" + minute + ":" + second;
			} else if (type == 7) {
				var dateTime = show_day[tian];
			}
			return dateTime;
		}
		function getSubStr (str){
			if(str.length<=15){
				return str;
			}
		var subStr1 = str.substr(0,10);
		var subStr2 = str.substr(str.length-5,5);
		var subStr = subStr1 + "..." + subStr2 ;
		return subStr;
	}
	function checktype(type){
	var type_arr = ['ara','gif','html','jpg','png','ppt','txt','word','xsl','zip'];
	index = type_arr.indexOf(type);
	if(index==-1){
		return 'undefined';
	}
	return type;
	}
	function openfile(url) {
		var obj =url.lastIndexOf("/");
		var filename = url.substr(obj+1);
		if(url){
			var downloadManager = api.require('downloadManager');
			downloadManager.enqueue({
				url: url,
				savePath: 'fs://file/'+filename,
				cache: true,
				allowResume: true,
				title: '文件',
				networkTypes: 'all'
		}, function(ret, err) {
			downloadManager.openDownloadedFile({
					id: ret.id
			}, function(ret1, err1) {
					if (ret.status) {
					} else {
						api.toast({
							msg : '打开文件失败',
							duration : 1000,
							location : 'center'
						});
					}
			});
		});

		}
		function jtcallback(){
			var rong = api.require('rongCloud2');
			rong.setOnMessageRecalledListener(function(ret){
				$api.remove($api.dom('.item'+ret.messageId));

										})
		}

	}
	function isURL(value) {
					 var strRegex = "^((https|http|ftp|rtsp|mms)://)?[a-z0-9A-Z]{3}\.[a-z0-9A-Z][a-z0-9A-Z]{0,61}?[a-z0-9A-Z]\.com|net|cn|cc (:s[0-9]{1-4})?/$";
					 var re = new RegExp(strRegex);
					 if (re.test(value)) {
							 return true;
					 } else {
								return false;
					 }
			 }


	</script>
</html>
